home *** CD-ROM | disk | FTP | other *** search
- /*
- File: TSNMP.h
-
- Contains: SNMP Class declarations
-
- Copyright: © 1991-1992 by Apple Computer, Inc., all rights reserved.
-
- */
- #ifndef __TSNMP__
- #define __TSNMP__
-
-
- /**********************************************************************
- ** Includes
- **********************************************************************/
-
- #ifndef __LIBRARYMANAGER__
- #include <LibraryManager.h>
- #endif
-
- #ifndef __SNMP__
- #include <SNMP.h>
- #endif
-
- #ifndef __MEMORY__
- #include <Memory.h>
- #endif
-
- #ifndef __ALIASES__
- #include <Aliases.h>
- #endif
-
- /**********************************************************************
- ** Class Definitions
- ***********************************************************************/
-
- // structure type references
-
- class TSNMPAgent;
- class TSNMPVar;
- class TSNMPManagerPrv;
- class TSNMPMIBNode;
-
- /**********************************************************************
- ** Library IDs
- ***********************************************************************/
- #define kLIB_SNMPID "snmp:mgr$"
- #define kLIB_AgentID "snmp:agt$"
-
- /**********************************************************************
- ** Class IDs
- ***********************************************************************/
- #define kTSNMPManagerID "snmp:mgr$TSNMPManager"
- #define kTSNMPConsoleID "snmp:mgr$TSNMPConsole"
- #define kTSNMPAgentID "snmp:mgr$TSNMPAgent"
- #define kTSNMPVarID "snmp:mgr$TSNMPVar"
- #define kTDevSNMPVarID "snmp:mgr$TDevSNMPVar"
-
- /**********************************************************************
- ** Class TSNMPManager. Don't subclass, use TSNMPAgent::fSNMPManagerPtr.
- ***********************************************************************/
-
- class TSNMPManager : public TDynamic
- {
- public:
- TSNMPManager();
- virtual ~TSNMPManager();
-
- // Agent routines
-
- virtual OSErr AddGroup(
- TSNMPAgent* theAgentPtr, // who wants to give a group name to a subtree
- ObjectIDPtr theGroupIdPtr, // all ids below this show up inside the group
- StringPtr theGroupNamePtr, // the name that shows in the UI
- short descResID, // resource id of description resource
- short descStrIndex ) = 0; // index of desc string in desc string STR# resource
-
- virtual OSErr SendTrap(
- SNMPTrapCode generic, // values defined in the SMI (RFC 1155)
- short specific, // developer defined error extensions
- ObjectIDListPtr idListPtr ) = 0; // variables sent in the trap packet
-
- // Variable routines
-
- virtual OSErr AddMIBVar( // must InitTSNMPVar() first
- TSNMPVar* theVarPtr, // the variable to add
- StringPtr varNamePtr) = 0; // the name that shows in the UI
-
- virtual OSErr GetVariableInfo(
- ObjectIDListPtr idListPtr, // unique specifiers for a set of variables
- short next, // a powerful get-next request?
- Ptr mibletBufferPtr, // description and value of the variables
- Size bufferSize ) = 0; // how much space available in miblet buffer
-
- // Registration completion notification
-
- virtual OSErr RegisterDone(
- TSNMPAgent* agent) = 0; // the agent which has completed registration
-
-
- // interface routine
-
- virtual unsigned long GetIFindex( // used by agents to get the if index of
- short description, // Network devices
- char location) = 0; // descriptions & locations are found in SNMP.h
-
- };
-
-
- /**********************************************************************
- ** Class TSNMPAgent
- ***********************************************************************/
-
- class TSNMPAgent: public TDynamic
- {
- public:
- TSNMPAgent(); // fills in fSNMPManager
- virtual ~TSNMPAgent();
-
- virtual OSErr InitSNMPAgent(
- StringPtr agentNamePtr, // name of the agent that shows in the UI
- short descResID, // resource id of description STR#
- short descStrIndex, // index in description STR# of agent description
- short agentVersion); // version # of the agent -- values 0 and all negative
- // values are reserved
-
- virtual OSErr GetAgentFSSpec(
- FSSpec *aFSSpecPtr); // where variable descriptions are kept
-
- friend TSNMPManagerPrv;
-
- protected:
- TSNMPManager* fSNMPManagerPtr; // for SNMPManager calls described above
- TLibraryFile* fAgentLibraryPtr;
-
- private:
- char fAgentName[33];
- short fDescResID;
- short fDescStrIndex;
- short fAgentVersion;
- };
-
-
- /**********************************************************************
- ** Class TSNMPVar
- ***********************************************************************/
-
- class TSNMPVar : public TDynamic
- {
- public:
- TSNMPVar();
- virtual ~TSNMPVar();
-
- virtual OSErr InitSNMPVar( // must call inherited if overridden
- TSNMPAgent* agentPtr, // agent that implements this variable
- ObjectIDPtr idPtr, // varible's object ID
- short precedence, // lowest precedence gets priority
- ASNTagType type, // describes variable's encoding
- SMIAccess access, // maximum access allowed
- short descResID, // resource id of description STR# resource
- short descStrIndex); // index of description string in STR# resource
-
- TSNMPAgent* GetAgentPtr();
-
- friend TSNMPManagerPrv;
- friend TSNMPMIBNode;
- friend TSNMPPrefixNode;
- friend TSNMPEndNode;
-
- private:
-
- virtual ObjectIDPtr GetIDPtr();
-
- ObjectIDPtr fIDPtr;
- TSNMPAgent* fAgentPtr;
- short fPrecedence;
- ASNTagType fType;
- SMIAccess fAccess;
- short fDescResID;
- short fDescStrIndex;
- long fCommunities;
- TSNMPMIBNode *fParentNode;
- unsigned long fSubID;
-
- };
-
- /**********************************************************************
- ** Inline Member Functions
- ***********************************************************************/
-
- inline TSNMPAgent*
- TSNMPVar::GetAgentPtr() { return fAgentPtr; }
-
-
- /**********************************************************************
- ** Class TDevSNMPVar must be subclassed by developers for their variables
- ***********************************************************************/
-
- class TDevSNMPVar : public TSNMPVar
- {
- public:
- TDevSNMPVar();
- virtual ~TDevSNMPVar();
-
- virtual OSErr GetVariable(
- Boolean next, // if true then it is a get next request
- ObjectIDPtr varOIDPtr, // unique id for variable
- VarBuf* valuePtr ) = 0; // where to place the value returned
-
- virtual OSErr SetVariable(
- ObjectIDPtr varOIDPtr, // unique id for variable
- VarBuf* valuePtr, // value to set variable to
- SetStage action ) = 0; // for 'simultaneous' sets
- };
-
-
-
- /**********************************************************************
- ** Class TSNMPConsole must be subclassed by developers for a console
- ***********************************************************************/
-
- class TSNMPConsole : public TDynamic
- {
- public:
- TSNMPConsole();
- virtual ~TSNMPConsole();
-
- virtual OSErr ReceiveRawPacket( // must override
- PacketPiecePtr packetPtr, // raw SNMP Trap packet
- TIAddressPtr source); // where the packet came from
-
- private:
- TSNMPManager* fSNMPManagerPtr; // Pointer to the manager
- SNMPRefNum* fConsoleInfoPtr; // Pointer to console info
- };
-
- #endif __TSNMP__